home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / INVR.N < prev    next >
Text File  |  1995-11-08  |  13KB  |  356 lines

  1. Define PeriodStartEndGet(title, ps, pe) {
  2.     scr = SdCreate(, -2, -2, 7, 40, title);
  3.     fromDate = DateMonthStart(DateToday());
  4.     toDate   = DateMonthEnd(DateToday());
  5.     while (1) {
  6.         SdPrompt(scr, 1,  9, "From Date  :");
  7.         SdDate  (scr, "from",  1,  1, 22, 10, &fromDate);
  8.         SdPrompt(scr, 3,  9, "To Date    :");
  9.         SdDate  (scr, "to",    1,  3, 22, 10, &toDate);
  10.         SdButton(scr, "ok",    1,  5,  9, 10, "OK", "", 1);
  11.         SdButton(scr, "can",   1,  5, 22, 10, "Cancel", "", 2);
  12.  
  13.         if ((cmd = SdEdit(scr)) == 1) {
  14.             SdUpdate(scr);
  15.             if (fromDate > toDate) {
  16.                 MsgWait("", "From Date must not be after To Date.");
  17.                 continue;
  18.             }
  19.             ps = fromDate;
  20.             pe = toDate;
  21.         }
  22.         break;
  23.     }
  24.     SdDestroy(scr);
  25.     return cmd;
  26. }
  27. Define PeriodEndGet(title, pe) {
  28.     scr = SdCreate(, -2, -2, 5, 40, title);
  29.     month = DateMonth(DateToday());
  30.     year  = DateYear(DateToday());
  31.  
  32.     SdPrompt(scr, 1,  3, "Period - Month :");
  33.     SdInt   (scr, "mth",  1,  1, 21, 2, &month);
  34.     SdPrompt(scr, 1, 26, "Year :");
  35.     SdInt   (scr, "year", 1,  1, 33, 4, &year);
  36.     SdButton(scr, "ok",   1,  3,  9, 10, "OK", "", 1);
  37.     SdButton(scr, "can",  1,  3, 22, 10, "Cancel", "", 2);
  38.  
  39.     while ((cmd = SdEdit(scr, cursor)) == 1) {
  40.         SdUpdate(scr);
  41.         if (month < 0 || month > 12) {
  42.             MsgWait("", "Invalid month name");
  43.             cursor = "mth";
  44.             continue;
  45.         }
  46.         if (year < 1900) {
  47.             MsgWait("", "Invalid year number");
  48.             cursor = "mth";
  49.             continue;
  50.         }
  51.         pe = DateMonthEnd(StrCat("1/", month, "/", year));
  52.         break;
  53.     }
  54.     SdDestroy(scr);
  55.     return cmd;
  56. }
  57. Define InvSummPage(page, line, linesperpage, doc, fmtH1, fmtH2, client, periodName, periodYear) {
  58.     if (page)
  59.         PdPageFeed(doc);
  60.     line = linesperpage;
  61.     PdWrite(doc, PfFormat(fmtH1, "", page = page + 1));
  62.     attnPrompt = attn = "";
  63.     if (page == 1) {
  64.         PdLineFeed(doc, 14);
  65.         line = line - 14;
  66.         if (attn = univ^clnt^[client]^attn)
  67.             attnPrompt = "ATTENTION:";
  68.     }
  69.     PdWrite(doc, PfFormat(fmtH2, "", 
  70.                         attnPrompt, attn,
  71.                         univ^clnt_code^[client],
  72.                         StrCat("Fees Due for Month of ", 
  73.                                periodName, ", ", periodYear)));
  74. }
  75. Define InvSummParams(pe, clientStart, clientEnd, orderBranch) {
  76.     scr = SdCreate(, -2, -2,  9, 55, "Monthly Invoice Summary");
  77.     month = DateMonth(DateToday());
  78.     year  = DateYear(DateToday());
  79.  
  80.     SdPrompt(scr, 1,  3, "Period - Month :");
  81.     SdInt   (scr, "mth",  1,  1, 21, 2, &month);
  82.     SdPrompt(scr, 1, 26, "Year :");
  83.     SdInt   (scr, "year", 1,  1, 33, 4, &year);
  84.     SdCheck (scr, "sgle", 1,  3,  3, 17, &sgle, "Single Client", "s", 31);
  85.     SdPrompt(scr, 3, 25, "Client Code :");
  86.     SdCombo (scr, "clnt", 0,  3, 39, 12, 10, &clnt, "univ^clnt_code^");
  87.     SdCheck (scr, "ordr", 1,  5,  3, 28, &ordr, "Order Invoices by Branch", "b");
  88.     SdButton(scr, "ok",   1,  7, 16, 10, "OK", "", 1);
  89.     SdButton(scr, "can",  1,  7, 29, 10, "Cancel", "", 2);
  90.  
  91.     while (1) {
  92.         cmd = SdEdit(scr, cursor);
  93.         SdUpdate(scr);
  94.         if (cmd == 31) {                // single client checkbox
  95.             SdModeSet(scr, sgle, "clnt");
  96.             if (sgle)
  97.                 cursor = "clnt";
  98.             else
  99.                 cursor = "n";           // next field
  100.             continue;
  101.         }
  102.         else if (cmd == 1) {
  103.             if (month < 0 || month > 12) {
  104.                 MsgWait("", "Invalid month name");
  105.                 cursor = "mth";
  106.                 continue;
  107.             }
  108.             if (year < 1900) {
  109.                 MsgWait("", "Invalid year number");
  110.                 cursor = "mth";
  111.                 continue;
  112.             }
  113.             if (sgle && !univ^clnt_code^[clnt]) {
  114.                 MsgWait("", "Client Code selected does not exist");
  115.                 cursor = "clnt";
  116.                 continue;
  117.             }
  118.             pe = DateMonthEnd(StrCat("1/", month, "/", year));
  119.             if (sgle)
  120.                 clientStart = clientEnd = clnt;
  121.             orderBranch = ordr;
  122.         }
  123.         break;
  124.     }
  125.     SdDestroy(scr);
  126.     return cmd;
  127. }
  128. Define InvSummary(argPe) {
  129.     if (InvSummParams(&periodEnd, &clientStart, &clientEnd, &orderBranch) != 1)
  130.         return;
  131.  
  132.     periodName  = DateMonthName(periodEnd);
  133.     periodYear  = DateYear(periodEnd);
  134.  
  135.     scr = MsgCreate("Invoice Summary Progress");
  136.  
  137.     fmtH1 = PfCreate();
  138.     PfInt   (fmtH1, 0, 55, 3);
  139.     PfPrompt(fmtH1, 0, 59, "of");
  140.  
  141.     fmtH2 = PfCreate();
  142.     PfString(fmtH2, 0,  0, 10);         /* attention */
  143.     PfString(fmtH2, 0, 12, 40);
  144.     PfString(fmtH2, 2,  0, 63, "c");
  145.     PfString(fmtH2, 3,  0, 63, "c");
  146.     PfPrompt(fmtH2, 5,  0, "   DATE");
  147.     PfPrompt(fmtH2, 5, 13, "CLIENTS NAMES");
  148.     PfPrompt(fmtH2, 5, 57, "AMOUNT"); 
  149.  
  150.     fmtD = PfCreate();
  151.     PfDate  (fmtD,  0,  0, 10);
  152.     PfString(fmtD,  0, 13, 40);
  153.     PfFloat (fmtD,  0, 53, 10, 2);
  154.  
  155.     fmtL = PfCreate();
  156.     PfString(fmtL,  0, 13, 40);
  157.  
  158.     fmtB = PfCreate();
  159.     PfString(fmtB,  0,  0,  50);
  160.  
  161.     fmtT = PfCreate();
  162.     PfString(fmtT,  1,  0, 40);
  163.     PfFloat (fmtT,  1, 53, 10, 2);
  164.  
  165.     fmtF = PfCreate();
  166.     PfPrompt(fmtF,  4,  0, univ^spar^invs1);
  167.     PfPrompt(fmtF,  5,  0, univ^spar^invs2);
  168.     PfPrompt(fmtF,  6,  0, univ^spar^invs3);
  169.     PfPrompt(fmtF,  7,  0, univ^spar^invs4);
  170.  
  171.     linesperpage = line = parm^page^def^height -
  172.                           parm^page^def^margin^top -
  173.                           parm^page^def^margin^bottom -
  174.                           7;
  175.     append = parm^prt^def^append; 
  176.     client = clientStart;
  177.     branch = date = code = "";
  178.     while (1) {
  179.         if (orderBranch) {
  180.             Explode(next(data^inv_mecb^[periodEnd]^[client]^[branch]^[date]^[code]), 
  181.                     "^", 
  182.                     &p1, &p2, &clientN, &branchN, &date, &code);
  183.  
  184.             end = p1 != "inv_mecb" || p2 != periodEnd 
  185.                                    || (clientEnd && clientN  > clientEnd);
  186.         }
  187.         else {
  188.             Explode(next(data^inv_mecl^[periodEnd]^[client]^[date]^[code]), 
  189.                     "^", 
  190.                     &p1, &p2,
  191.                     &clientN, &date, &code);
  192.                     branchN = "";           // these branch vars could go
  193.  
  194.             end = p1 != "inv_mecl" || p2 != periodEnd 
  195.                                    || (clientEnd && clientN > clientEnd);
  196.         }
  197.         if (abort = MsgShow(scr, clientN . "  " . branchN .  
  198.                                  ",  Invoice " . code)) {
  199.             if (doc)
  200.                 PdClose(doc, abort);
  201.             break;
  202.         }
  203.         if (end || clientN != client) {
  204.             if (doc) {
  205.                 if (line < 11)
  206.                     InvSummPage(&page, &line, linesperpage, doc, fmtH1, fmtH2, 
  207.                                 client, periodName, periodYear);
  208.                 PdWrite(doc, PfFormat(fmtT, "", 
  209.                     StrCat(periodName, ", ", periodYear, " Total"), total));
  210.                 PdWrite(doc, PfFormat(fmtF, ""));
  211.  
  212.                 PdClose(doc, 0);
  213.                 doc = 0;
  214.             }
  215.             if (end)
  216.                 break;
  217.         }
  218.         if (!doc) {
  219.             doc = PdCreate(parm^prt^def^name, "InvSumm", append,
  220.                         parm^prt^def^copies, parm^prt^def^browse, 
  221.                         0, 62, 0, "",
  222.                         parm^prt^def^start, parm^prt^def^end);
  223.             append = "y";
  224.             PdPageSize(doc, parm^page^def^height, parm^page^def^width,
  225.                             parm^page^def^margin^top, parm^page^def^margin^bottom,
  226.                             parm^page^def^margin^left, parm^page^def^margin^right);
  227.             page =
  228.             line = 0;
  229.             total = 0.00;
  230.             branch = "";
  231.         }
  232.         if (branchN != branch) {
  233.             if (line < 2)
  234.                 InvSummPage(&page, &line, linesperpage, doc, fmtH1, fmtH2, 
  235.                             clientN, periodName, periodYear);
  236.             PdWrite(doc, PfFormat(fmtB, "", branchN));
  237.             line = line - 1;
  238.         }
  239.         if (line < 2)
  240.             InvSummPage(&page, &line, linesperpage, doc, fmtH1, fmtH2,
  241.                         clientN, periodName, periodYear);
  242.         PdWrite(doc, PfFormat(fmtD, "",
  243.                               data^inv^[code]^date,
  244.                               data^inv^[code]^appl,
  245.                               amt = data^inv^[code]^base +
  246.                                     data^inv^[code]^extr));
  247.         PdWrite(doc, PfFormat(fmtL, "", data^inv^[code]^loan));
  248.         line = line - 2;
  249.  
  250.         total = total + amt;
  251.  
  252.         client = clientN;
  253.         branch = branchN;
  254.     }
  255.     PfDestroy(fmtF);
  256.     PfDestroy(fmtT);
  257.     PfDestroy(fmtB);
  258.     PfDestroy(fmtL);
  259.     PfDestroy(fmtD);
  260.     PfDestroy(fmtH1);
  261.     PfDestroy(fmtH2);
  262.     MsgDestroy(scr);
  263. }
  264. Define InvRepMonth() {
  265.     if (PeriodEndGet("Monthly Invoice Report", &periodEnd) != 1)
  266.         return;
  267.     periodName  = DateMonthName(periodEnd);
  268.     periodYear  = DateYear(periodEnd);
  269.     title = StrCat("Monthly Invoice Report for ", periodName, ", ", periodYear);
  270.  
  271.     doc = PdCreate(parm^prt^def^name, "InvRepMth", parm^prt^def^append, 
  272.                    parm^prt^def^copies, parm^prt^def^browse, 
  273.                    0, 120, 0, "",
  274.                    parm^prt^def^start, parm^prt^def^end);
  275.     PdPageSize(doc, parm^page^def^height, parm^page^def^width,
  276.                     parm^page^def^margin^top, parm^page^def^margin^bottom,
  277.                     parm^page^def^margin^left, parm^page^def^margin^right);
  278.     scr = MsgCreate("Monthly Invoice Report");
  279.  
  280.     head = PfCreate();
  281.     PfPrompt(head, 0,  0, univ^spar^coname);
  282.     PfPrompt(head, 0, 85, DateToday());
  283.     PfPrompt(head, 0, 97, TimeNow());
  284.     PfString(head, 0,106, 10, "R");
  285.     PfPrompt(head, 0,117, "of");
  286.     PfString(head, 2,  0, 124, "C");
  287.     PfPrompt(head, 4,  0, "Date");
  288.     PfPrompt(head, 4, 12, "Applicant and Property Address");
  289.     PfPrompt(head, 4, 68, "Base   Extra  Client   Branch   Valuation  Inv No  Job No");
  290.     PfPrompt(head, 5,  0, " ");
  291.  
  292.     dtl = PfCreate();
  293.     PfDate  (dtl,  0,  0, 10);
  294.     PfString(dtl,  0, 12, 50);
  295.     PfFloat (dtl,  0, 62, 10, 2);
  296.     PfFloat (dtl,  0, 72,  8, 2);
  297.     PfString(dtl,  0, 82,  8);
  298.     PfString(dtl,  0, 91,  8);
  299.     PfInt   (dtl,  0,100,  9);
  300.     PfInt   (dtl,  0,111,  6);
  301.     PfInt   (dtl,  0,119,  6);
  302.     PfString(dtl,  1, 12, 100);
  303.  
  304.     tot = PfCreate();
  305.     PfPrompt(tot,  1,  0, "Totals");
  306.     PfPrompt(tot,  0, 62, " _________");
  307.     PfPrompt(tot,  0, 72, " _______");
  308.     PfFloat (tot,  1, 62, 10, 2);
  309.     PfFloat (tot,  1, 72,  8, 2);
  310.  
  311.     PdWrite(doc, PfFormat(head, "", StrCat("page ", page = page + 1), title));
  312.     line = linesperpage = parm^page^def^height -
  313.                           parm^page^def^margin^top - parm^page^def^margin^bottom - 4;
  314.     date = DateMonthStart(periodEnd);
  315.     code = "";
  316.     while (1) {
  317.         Explode(next(data^inv_date^[date]^[code]), "^", &p1, &date, &code);
  318.  
  319.         if (p1 != "inv_date" || date > periodEnd)
  320.             break;
  321.  
  322.         if (abort = MsgShow(scr, "Invoice " . code))
  323.             break;
  324.         if (line <= 2) {
  325.             if (page)
  326.                 PdPageFeed(doc);
  327.             PdWrite(doc, PfFormat(head, "", 
  328.                                   StrCat("page ", page = page + 1), title));
  329.             line = linesperpage;
  330.         }
  331.         totBase = totBase + (base = data^inv^[code]^base);
  332.         totExtr = totExtr + (extr = data^inv^[code]^extr);
  333.         PdWrite(doc, PfFormat(dtl, "", 
  334.                               data^inv^[code]^date, 
  335.                               data^inv^[code]^appl, 
  336.                               base, 
  337.                               extr, 
  338.                               data^inv^[code]^clnt, 
  339.                               data^inv^[code]^brch, 
  340.                               data^inv^[code]^vamt, 
  341.                               code,
  342.                               data^inv^[code]^job, 
  343.                               StrCat(data^inv^[code]^add1, "  ",
  344.                                      data^inv^[code]^add2)));
  345.  
  346.         line = line - 3;
  347.     }
  348.     PdWrite(doc, PfFormat(tot, "", totBase, totExtr));
  349.     PfDestroy(head);
  350.     PfDestroy(dtl);
  351.     PfDestroy(tot);
  352.     MsgDestroy(scr);
  353.     PdClose(doc, abort);
  354. }
  355.  
  356.